<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<% String path = pageContext.getServletContext().getContextPath();%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>门诊挂号</title>

 <link href="<%=path %>/bootstrap/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet">
<link href="<%=path %>/bootstrap/bootstrap-3.3.7-dist/css/bashboard.css" rel="stylesheet">
<link href="<%=path %>/bootstrap/bootstrap-validator/dist/css/bootstrapValidator.min.css" rel="stylesheet">
	
<script type="text/javascript" src="<%=path %>/bootstrap/bootstrap-3.3.7-dist/js/jquery-1.11.1.min.js"></script>
  <script type="text/javascript" src="<%=path %>/bootstrap/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
  <script type="text/javascript" src="<%=path %>/bootstrap/bootstrap-validator/dist/js/bootstrapValidator.min.js"></script>
 
   <script type="text/javascript" src="<%=path %>/js/My97DatePicker/WdatePicker.js"></script>
   <style>
	   body{font-family:"微软雅黑";padding-top:10px;margin:0px;}
	   .labelField{width:130px;}
	   .form-group{padding-bottom:15px;padding-left:20px;}
	   .dropul li{float:left; width:460px;}
	   .dropul{width:460px;height:200px;overflow:auto;}
	   .dropDown_title span{display:block;width:150px;float:left;border-bottom:solid 1px #ccc; text-align:center;font-weight:bold;}
	   .dropDown_rows span{display:block;width:150px;float:left;border-bottom:solid 1px #ccc;   }
	</style>
    <script type="text/javascript">
       $(document).ready(function(){//页面文本加载完毕后执行该方法
       		$("#addPatientForm").bootstrapValidator({
                feedbackIcons: {
                    valid: "glyphicon glyphicon-ok",
                    invalid: "glyphicon glyphicon-remove",
                    validating: "glyphicon glyphicon-refresh"
                }, fields:{
                    idNumber:{
                        validators: {
                            notEmpty: {
                                message: "身份证号码不能为空"
                            }, 
                            trigger: "change",
                            stringLength: {//检测长度           
                                min: 1,            
                                max: 20,
								message: "长度必须在1-20之间"
								},                          
						/* 	regexp: {
  								regexp: /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9X]$/,                              
   								message: "所输入格式错误"           
   							} */
                        }
                    } ,
                    name:{
                        validators: {
                            notEmpty: {
                                message: "姓名不能为空"
                            }, 
                            trigger: "change"
                             
                        }
                    },
                    age:{
                        validators: {
                            notEmpty: {
                                message: "年龄不能为空"
                            }, 
                            trigger: "change",                          
							regexp: {
								//正则验证                              
  								regexp:/^[1-9][0-9]{1,2}$/,                              
   								message: "请输入正确年龄"           
   							}
                             
                        }
                    } ,
                    parentidnumber:{
                        validators: {
                            
                            stringLength: {//检测长度           
                                min: 1,            
                                max: 20,
								message: "长度必须在1,20之间"
								},                          
							/* regexp: {
								//正则验证                              
  								regexp: /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9X]$/,                              
   								message: "所输入格式错误"           
   							} */
                        }
                    } 
                     
                     
                }

            });
       
       });
    
       //打开病人信息添加model（遮罩层）
       function openAddPtModel(){  
          $("#myModal").modal("show");  
       }
       //保存病人信息
       function savePatient(){
           //表单格式校验
           $("#addPatientForm").bootstrapValidator();
           //获取表单中提交的数据
         	var items=  $("#addPatientForm").serialize();//数据格式：name属性值=值&name属性值=值
         	 
         	//提交表单动作，目的是为为格式校验注意：form不写action属性
          	$("#addPatientForm").submit();
         	if($("#addPatientForm").data("bootstrapValidator").isValid()){//表单校验成功提交请求
		            
         		
         		$.ajax({
        			url:"<%=path %>/opreg/addPatient",
        			data:{card_id:card_id,patient_name:patient_name,patient_sex:patient_sex,patient_age:patient_age,
        				patient_born:patient_born,patient_address:patient_address,patient_idcard:patient_idcard,
        				patient_tel:patient_tel,patient_country:patient_country,patient_race:patient_race,
        				patient_edu:patient_edu,patient_job:patient_job,patient_xuexing:patient_xuexing,patient_hunyin:patient_hunyin
        				,patient_idaddress:patient_idaddress},
        			/*dataType:"json",*/
        			success:function(data,textStatus){
        				if(textStatus=="success"){
        					
        					if(data==true){
        						alert("添加成功");
        						
        					/* 	$('#dg').datagrid('appendRow',{
        							card_id:card_id,
        							patient_name:patient_name,
        							patient_sex:patient_sex,
        							patient_age:patient_age,
        							patient_born:patient_born,
        							patient_address:patient_address,
        							patient_idcard:patient_idcard,
        							patient_tel:patient_tel,
        							patient_country:patient_country,
        							patient_race:patient_race,
        							patient_edu:patient_edu,
        							patient_job:patient_job,
        							patient_xuexing:patient_xuexing,
        							patient_hunyin:patient_hunyin,
        							patient_idaddress:patient_idaddress,
        							
        						}); */
        						onLoadSuccess();
        						$('#add').window("close");
        					}
        				}
        			},
        			error:function(data,textStatus){
        				alert("error:"+textStatus);
        			},
        		})
		            <%-- $.ajax({
		            url:"<%=path%>/opreg/addPatient",
		            type:"post",
		            dataType:"json",
		            data:items,//属性=值&属性=值  或者  {name:'JONES',age:12,....}
		            success:function(res){//success表示服务器端响应成功，数据为参数   
		               if(res){
		                  $("#namespan").html(res.name);
		                  $("#sexspan").html(res.sex);
		                  $("#agespan").html(res.age);
		                  $("#birthdayspan").html(res.birthday);
		                  $("#residentialAddrspan").html(res.registeredaddr);
		                  //关闭modal
		                   $("#myModal").modal("hide");
		                  //设置modal输入内容都只读或者不可用
		                   $("#name").attr("disabled","disabled");//readonly
		                   //保存成功设置其他病人信息字段都为只读，此处略，自己写
		                   
		                   //设置保存按钮不可用
		                   $("#savePatientBtn").attr("disabled","disabled");
		                  
		               }else{
		               	alert("保存失败！");
		               }
		            } ,
		            error:function(){
		              alert("系统响应失败！");
		            }
		         }); 
         	}else{
         		alert(false);
         	} --%>
        
       }
       
       
       //根据科室查询医生列表
       function searchPatients(obj){
           
        var  dept_id= obj.value;//获取被选中的科室ID
        alert(dept_id);
        //发送异步请求
        $.ajax({
          url:"<%=path%>/opreg/selectDoctors",
          data:{dept_id:dept_id},
          dataType:"json",
          type:"post",
          success:function(res){//[{},{}.....]
          
             //创建多个option
             if(res){    
                  var patientSelect=document.getElementById("patientSelect");//按照id找下拉列表
                  patientSelect.options.length=0;//清空数组数据，即清空选项
                  if(res.length<=0){//当点击 请选择，此时发送请求响应的数据不存在
                    patientSelect.options[0]=new Option("--请选择--","");
                    return;
                  }
                  
                for(var i=0;i<res.length;i++){
                    
                    var option=new Option(res[i].name,res[i].doctor_id);//创建option标签
                    
                    //向下拉列表中放option
                    patientSelect.options[i]=option;
                }
             } 
               
            
          },
          error:function(){
           alert("响应失败！");
          } 
        
        });
        
       }
       
       //点击 保存挂号单
       function saveRegisterInfo(){
         //获取病人名字和身份证号，查询，是否已填写病人信息
         alert("请输入病人信息");
         return false;
         }
       
       
 
       
    </script>
    
	  

</head>
<body>

			<!--toolsbar-->
			<div  class="panel panel-default">
			<div class="panel-heading">病人信息</div>
	        <div class="panel-body">
	         
				  <form  class="form-inline"  action="<%=path %>/opreg/selectPatients" method="post">
					  <div class="form-group">
					    <label for="regname" class="labelField">姓名：</label>
					    <input type="text" class="form-control" name="regName" id="regname" placeholder="请输入姓名">
					  </div>
					  <!--  <div class="form-group">
					    <label for="regname" class="labelField">身份证号：</label>
					    <input type="text" class="form-control" name="regCode" id="regCode" placeholder="请输入身份证号">
					  </div> -->
				
					  <div class="form-group">
					    <input type="submit"   value="查询" class="btn btn-primary">
					    <!-- <input type="button"   value="读卡" class="btn btn-primary"> -->
					  </div>
				    </form>
				  <br>
				   <form class="form-inline" id="saveRregisterForm"   method="post">
				   
				  
				  <div class="form-group">
				    <label for="account" class="labelField">费别：</label>
				     <select    class="form-control" name="costType" >
				      
				      <option value="1">自费</option>
				      <option value="2">公费</option>   
				    </select>
				  </div>
				  <div class="form-group">
				     <input type="button" class="btn btn-primary" value="注册病人" 
				     onclick="window.location.href=' <%=path%>/opreg/patientList';" >
				  </div>
				  
				   
				  <br>
				    <div class="form-group">
					    <label for="account" class="labelField">初复诊：</label>
					     <select   class="form-control" name="fsDiagnosis"  >
					     
					      <option value="1">初诊</option>
					      <option value="2">复诊</option>   
					    </select>
				   </div>
				   <div class="form-group">
					    <label for="account" class="labelField">挂号类别：</label>
					     <select   class="form-control"  name="registtype">
					     
					      <option value="1">普通号</option>
					      <option value="2">专家号</option>   
					    </select>
				    </div>
				     <div class="form-group">
					    <label for="account" class="labelField">选择科室：</label>
					     <select  id="dept_id" name="regDepartment"  class="form-control" onchange="searchPatients(this)" >
					      <option value="">--请选择--</option>
					      <c:forEach items="${departments}" var="d">
					         <option value="${d.dept_id}" >${d.dept_class}</option>
					      </c:forEach>
					      
					    </select>
				    </div>
				    <%-- <div class="form-group">
					    <label for="account" class="labelField" >医生：</label>
					       <select   class="form-control" id="patientSelect" name="doctorName">
					       <option value="">--请选择--</option>
					       <c:forEach items="${doctors}" var="d">
					         <option value="${d.doctor_id}">${d.doctor_name}</option>
					      </c:forEach>
					      
					         
					      
					      
					    </select>
				    </div> --%>
				    
					<table class="table" >
			                   <tbody>
									 
									<tr>
										<td>姓名：<span id="namespan">${entity.patient_name}</span></td>
										<td>性别：<span id="sexspan"><c:if test="${entity.patient_sex=='1'}">男</c:if><c:if test="${entity.patient_sex=='0'}">女</c:if></span></td>
										<td>年龄：<span id="agespan">${entity.patient_age}</span></td> 
										<%-- <td>出生日期：<span id="birthdayspan">${entity.patient_born}</span></td>
										<td>居住地址：<span id="residentialAddrspan">${entity.patient_address}</span></td> --%>
										<!-- <td>本日挂号次数：2</td>
										<td>病历号：1232313123</td> -->
									</tr>
									 
							   </tbody>	
              	   </table>
				    
	<!-- 			  挂号项目信息 
				   <table class="table table-striped" style="float:left;">
			                   <tbody>
									<tr>
										 <th>序号</th><th>项目</th><th>金额</th> 
										   
			 						</tr>
									<tr>
										<td>1</td>
										<td> 
											<select   class="form-control" >
					      						<option value="R">挂号</option>
					    					</select>
					    				</td>
					    				<td>
					    				 <input type="text" class="form-control" name="cost_0" value='0.00'    >
					    				</td> 
					    				 
									</tr>
									 
							   </tbody>	
              	   </table> -->
              	    
				   
				  <div style="clear:both;padding-left:260px;padding-top:30px;">
				  <a class="btn btn-primary" href="javascript:void(0);" 
				  onclick="var patient_idcard=$('#patient_idcard').val(); var dept_id=$('#dept_id').val();alert(dept_id);
				  window.location.href=' <%=path%>/opreg/addRegister?idnumber='+patient_idcard+'&dept_id='+dept_id;">确认挂号</a>
				  
				                                                                                                                                                             
				  
				  
				  <input type="button" class="btn btn-primary"  id="saveBtn"  onclick="saveRegisterInfo()" value="确认挂号"><!-- data-toggle="modal" data-target="#myModal" -->
				  <!--  <button type="button" class="btn btn-primary"  id="resetBtn" >取消</button>data-toggle="modal" data-target="#myModal" -->
				  </div>
			</form>
			 
		    </div>
		   </div>
		   
		   
		   <!-- 病人信息model -->
		   <!--遮罩层-->
<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    		 病人基本信息
                </h4>
            </div>
              <div class="modal-body"  >
                  <div class="panel-body">
                     
                      <form   class="form-inline" id="addPatientForm"   method='post'  >
                          <div class="form-group">
                              <label for="supplementid">卡类型</label>
                            	 <select   class="form-control" >
					      			<option value="c">磁卡</option>
					    		 </select>
                           </div>
                          <div class="form-group">
                              <label for="supplementdesc">卡号</label>
                              <input   class="form-control"  type='text'        id="cardNum" name='cardNum' >
                          </div>
                          <div class="form-group">
                              <label for=" ">身份证号</label>
                              <input  class="form-control"  <c:if test="${entity.card_id!=null}"> disabled</c:if>  type='text'  value="${entity.patient_idcard}"    id="patient_idcard"  name='patient_idcard'>
                           </div>
                           <div class="form-group">
                              <label for="name">姓名</label>
                              <input  class="form-control"    <c:if test="${entity.card_id!=null}"> disabled</c:if>   type='text'  value="${entity.patient_name}"     id="name"  name='name'>
                           </div>
                          <%--  <div class="form-group">
                              <label for=" ">性别</label>
                                   
                              		男：<input    <c:if test="${entity.card_id!=null}"> disabled</c:if> class="form-control"  type='radio' value="1"  <c:if test="${entity.patient_sex=='1'||entity.patient_sex==null}"> checked</c:if>       name='sex'>
              						女： <input  <c:if test="${entity.card_id!=null}"> disabled</c:if> class="form-control"  type='radio'   value="0"   <c:if test="${entity.patient_sex=='0'}"> checked</c:if>    name='sex'>
                           </div>
                           <div class="form-group">
                              <label for=" ">年龄</label>
                              <input  class="form-control"  type='text'    <c:if test="${entity.card_id!=null}"> disabled</c:if>   value="${entity.age}"    id="age"  name='age'>
                           </div>
                           <div class="form-group">
                              <label for=" ">出生日期</label>
                              <input  class="form-control" onFocus="WdatePicker()"   <c:if test="${entity.card_id!=null}"> disabled</c:if>  value="${entity.birthday}"	readonly   type='text'     id="birthday"  name='birthday'>
                           </div>
                           <div class="form-group">
                              <label for=" ">电话</label>
                              <input  class="form-control"  type='text'    <c:if test="${entity.card_id!=null}"> disabled</c:if>  value="${entity.phonenumber}"  id="phonenumber"  name='phonenumber'>
                           </div>
                           <div class="form-group">
                              <label for=" ">学校</label>
                              <input  class="form-control"  type='text'   <c:if test="${entity.card_id!=null}"> disabled</c:if>   value="${entity.school}"  id="school"  name='school'>
                           </div>
                           <div class="form-group">
                              <label for=" ">家长</label>
                              <input  class="form-control"  type='text'    <c:if test="${entity.card_id!=null}"> disabled</c:if>  value="${entity.parentname}"  id="parentName"  name='parentName'>
                           </div>
                            <div class="form-group">
                              <label for=" ">家长身份证号</label>
                              <input  class="form-control"  type='text'  <c:if test="${entity.card_id!=null}"> disabled</c:if>  value="${entity.parentidnumber}"  id="parentidnumber"  name='parentidnumber'>
                           </div>
                           <br>
                           <div class="form-group">
                              <label for=" ">居住地址</label>
                              <input  class="form-control"  type='text'  value="${entity.patient_address}"   id="residentialAddr"  name='residentialAddr'>
                           </div>
                           <div class="form-group">
                              <label for=" ">出生地址</label>
                              <input  class="form-control"  type='text'  value="${entity.birthplace}"    id="birthplace"  name='birthplace'>
                           </div>
                            <div class="form-group">
                              <label for=" ">户口地址</label>
                              <input  class="form-control"  type='text'   value="${entity.registeredaddr}"   id="registeredAddr"  name='registeredAddr'>
                           </div>
                           <div class="form-group">
                              <label for=" ">国籍</label>
                              <input  class="form-control"  type='text'   value="${entity.nationality}"    id="nationality"  name='nationality'>
                           </div>
                            <div class="form-group">
                              <label for=" ">民族</label>
                              <input  class="form-control"  type='text'    value="${entity.nation}"  id="nation"  name='nation'>
                           </div>
                            <div class="form-group">
                              <label for=" ">文化程度</label>
                              <input  class="form-control"  type='text'    value="${entity.education}"  id="education"  name='education'>
                           </div>
                            <div class="form-group">
                              <label for=" ">职业</label>
                              <input  class="form-control"  type='text'     value="${entity.vocation}"  id="vocation"  name='vocation'>
                           </div>
                            <div class="form-group">
                              <label for=" ">血型</label>
                              <select class="form-control"  id="bloodType"  name='bloodType'>
                                <option value="" <c:if test="${entity.bloodtype==null}"> selected</c:if>  >--请选择--</option>
                                <option value="A" <c:if test="${entity.bloodtype=='A'}"> selected</c:if>>--A型--</option>
                                <option value="AB" <c:if test="${entity.bloodtype=='AB'}"> selected</c:if>>--AB型--</option>
                                <option value="B" <c:if test="${entity.bloodtype=='B'}"> selected</c:if>>--B型--</option>
                                <option value="O" <c:if test="${entity.bloodtype=='O'}"> selected</c:if>>--O型--</option>
                              </select>
                                  
                           </div>
                            <div class="form-group">
                              <label for=" ">婚姻状况</label>
                              <select class="form-control" id="maritalStatus"  name='maritalStatus' >
                                <option value="" <c:if test="${entity.maritalstatus==null}"> selected</c:if>>--请选择--</option>
                                <option value="Y" <c:if test="${entity.maritalstatus=='Y'}"> selected</c:if>>已婚</option>
                                <option value="N" <c:if test="${entity.maritalstatus=='N'}"> selected</c:if>>未婚</option>
                                
                              </select>
                              
                           </div>
                           <br> --%>
                            
                           
                           <!-- 
                            <div class="form-group">
                              <label for=" ">凭证号</label>
                              <input  class="form-control"  type='text'     id=" "  name=' '>
                           </div> 
                            
                           <div class="form-group">
                              <label for=" ">医疗证号</label>
                              <input  class="form-control"  type='text'     id="medicalCertificateNum"  name='medicalCertificateNum'>
                           </div>
                           -->
                             
                            <%-- <div class="form-group">
                              <label for=" ">区县代码</label>
                              <input  class="form-control"  type='text'   value="${entity.countrycode}"   id="countryCode"  name='countryCode'>
                           </div> 
                           <div class="form-group">
                              <label for=" ">家庭编码</label>
                              <input  class="form-control"  type='text'     value="${entity.familynum}" id="familyNum"  name='familyNum'>
                           </div> --%>
                           
                          <div class="form-group" style="display:block;text-align:center;">

                          <button type="button" id="savePatientBtn" <c:if test="${entity.card_id!=null}"> disabled</c:if> onclick="savePatient()" class="btn btn-primary"  >保存</button>
                          <button type="button" class="btn btn-primary">取消</button>
                          </div>
                          </form>
                       

            </div>

        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal -->
    </div>
    </div>
             
       <!-- 病人信息model -->
		   <!--遮罩层-->
<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    		 找零
                </h4>
            </div>
            <!--   <div class="modal-body"  >
                 
                  <div class="panel-body">
                     
                      <form   class="form-inline"  id="zfForm"  method='post'  >
                          <div class="form-group">
                              <label for="supplementid">总金额</label>
                              <input  class="form-control"  type='text'     id="cost_1"  name='cost_1'>
                           </div>
                           <div class="form-group">
                              <label for="supplementid">舍入金额</label>
                              <input  class="form-control"  type='text'     id="cost_2"  name='cost_2'> 
                           </div>
                            <div class="form-group">
                              <label for="supplementid">可报金额</label>
                              <input  class="form-control"  type='text'     id="cost_3"  name='cost_3'> 
                           </div>
                            <div class="form-group">
                              <label for="supplementid">补偿金额</label>
                              <input  class="form-control"  type='text'     id="cost_4"  name='cost_4'> 
                           </div>
                            <div class="form-group">
                              <label for="supplementid">自费金额</label>
                              <input  class="form-control"  type='text'     id="cost_5"  name='cost_5'> 
                           </div>
                           <div class="form-group">
                              <label for="supplementid">支付方式</label>
                                <select   class="form-control" name="zf" >
					      			<option value="">现金</option>
					      			<option value="">储蓄卡</option>
					      			<option value="">医保</option>
					      			 
					    		 </select>
                           </div>
                           <div class="form-group">
                              <label for="supplementid">实际收款</label>
                              <input  class="form-control"  type='text'     id="cost_6"  name='cost_6'> 
                           </div>
                           <div class="form-group">
                              <label for="supplementid">找零</label>
                              <input  class="form-control"  type='text'     id="cost_7"  name='cost_7'> 
                           </div>
                           <div class="form-group" style="display:block;text-align:center;">

                          <button type="button" class="btn btn-primary" onclick="saveRegisterFn()"  >确定</button>
                          <button type="submit" class="btn btn-primary">取消</button>
                          </div>
                       </form>
                   </div>        
              </div> -->

        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal -->
</div>
 
  </body>

</html>
